#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	char arr[100] = { 0 };
	char arr2[100] = { 0 };
	int pre=0;
	int max=0;
	int i = 0;
	int j = 0;
	scanf("%s", arr);
	scanf("%s", arr2);
	//printf("%s\n", arr);
	//printf("%s\n", arr2);
	while (arr[i])
	{
		i++;
	}
	while (arr2[j])
	{
		j++;
	}
	i--;
	j--;

	int i1 = 0;
	int j1 = 0;
	
	while (arr[i] != arr2[j])
	{
		
		i--;
		j--;
		if (arr[i - 1] == arr2[j])
			break;
	}

	max = i;
 	while (i1 <= i && j1 <= j)
	{
		if (arr[i1] != arr2[j1])
		{
			int flag = 0;
			if (arr[i1] == arr[j1 - 1])
				j1--;
			else if (arr[i1 - 1] == arr2[j1])
			{
				
				i1--;
			}
			else if (arr[i1] == arr2[j1 + 1])
			{
				if (arr[i1 + 1] == arr2[j1])
					i1++;
				else
				j1++;
			}
			else if (arr[i1 + 1] == arr2[j1])
				i1++;
			
			pre = i1;
		}
		if (arr[i] != arr2[j])
		{
			if (arr[i - 1] == arr2[j])
				i--;
			else if (arr[i + 1] == arr2[j])
			{
				
				i++;
			}
			else if (arr[i] == arr[j - 1])
				j--;
			
			else if (arr[i] == arr2[j + 1])
				j++;
			
			
			max=i;
		}
		i1++;
		j1++;
		i--;
		j--;
		
	}
	
	int m = pre;
	if (max - pre < i - j+3)
		m = max;
	for (m; m <= max; m++)
		printf("%c", arr[m]);
 }
 